using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace FadeJSON
{
    /// <summary>
    /// true/false
    /// </summary>
    public class JsonBoolean : JsonBaseType
    {
        /// <summary>
        /// true/false
        /// </summary>
        private readonly bool vBoolean;

        /// <summary>
        /// true/false
        /// </summary>
        public override dynamic Value { get { return this.vBoolean; } }

        #region ctor

        /// <summary>
        /// true/false
        /// </summary>
        /// <param name="value"></param>
        public JsonBoolean(bool value)
        {
            vBoolean = value;
        }

        #endregion

        public override bool Equals(JsonBaseType other)
        {
            var right = other as JsonBoolean;

            return (right != null) && (this.vBoolean == right.vBoolean);
        }

        public static implicit operator JsonBoolean(bool value)
        {
            return new JsonBoolean(value);
        }

        public static implicit operator bool(JsonBoolean obj)
        {
            return obj.vBoolean;
        }

        internal override void ToString(StringBuilder builder, ref int tab)
        {
            builder.Append(vBoolean ? "true" : "false");
        }

    }

}